import '../model/result_model.dart';
import '../model/test_student_score_model.dart';
import '../utils/request.dart';

///考试:学生成绩:接口
class TestStudentScoreApi {
  TestStudentScoreApi._();

  static final _singleton = TestStudentScoreApi._();

  factory TestStudentScoreApi() => _singleton;

  ///查询
  Future<TestStudentScoreQueryRes> query(final TestStudentScoreQueryReq req) =>
      request
          .getHandler(
            path: '/exam/${req.examId}/test-score',
            params: req.toMap(),
          )
          .then((res) => TestStudentScoreQueryRes.fromModel(res));

  ///加载
  Future<TestStudentScoreInfoRes> info(final String id) => request
      .getHandler(path: '/exam/test-score/$id')
      .then((res) => TestStudentScoreInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final TestStudentScoreAddReq req) => request
      .postHandler(path: '/exam/${req.examId}/test-score', data: req.toMap());

  ///修改
  Future<BaseModelRes> modify(final TestStudentScoreModifyReq req) =>
      request.putHandler(path: '/exam/test-score/${req.id}', data: req.toMap());

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/exam/test-score/$id');
}

///考试:学生成绩:接口单例
final testStudentScoreApi = TestStudentScoreApi();
